package comOne.dao;

import com.util.JdbcUtils;
import comOne.domain.Studnets;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;


public class LoginStudentdao implements logindao {
    @Override
    public List<Studnets> list() {
       List<Studnets> list = new ArrayList<>();
        try {
            Connection connection = JdbcUtils.getConnection();
            PreparedStatement pas = connection.prepareStatement("select *from students ");
            ResultSet resultSet = pas.executeQuery();
            while (resultSet.next()) {
                String username1 = resultSet.getString("username");
                String password1 = resultSet.getString("password");
                Studnets stu = new Studnets(username1, password1);
                list.add(stu);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
}










